clear all
set more off

local out2="\outregsQJE\"
cd "\workfiles"

use step001_QJE_2, clear


tsset firm_id time

keep if treatment_old~=.

*** construct continuous measure of export
gen export4R=(1+2/3)/2  		if export4==1
replace export4R=(1/3+2/3)/2  	if export4==2
replace export4R=(1/3+0)/2  	if export4==3
replace export4R=0			  	if export4==4

gen abs_dlnL=abs(d.lnL)


keep if time>=211 & time<=227

collapse (mean) treatment_old peso lnL  dpre export4R /// /*objective measures */
		 (mean) sitgen sitimp5 promig ///  /*optimism */
		 (first) setton5 setton3 area, ///
		 by(firm_id)
		 
gen flag=1-(treatment_old==0 | treatment_old==1)
drop if flag==1
		 
reg treatment_old lnL [aw=peso], robust
local pF=Ftail(150,3,e(F))
outreg2 using "`out2'selection.dta", replace dec(3) ///
	addstat("p-value (F stat)",`pF')	
 
reg treatment_old lnL export4R [aw=peso], robust
local pF=Ftail(150,3,e(F))
outreg2 using "`out2'selection.dta", append dec(3)  ///
	addstat("p-value (F stat)",`pF')
	
reg treatment_old lnL export4R dpre [aw=peso], robust
local pF=Ftail(150,3,e(F))
outreg2 using "`out2'selection.dta", append  dec(3) ///
	addstat("p-value (F stat)",`pF')	

reg treatment_old i.area i.setton3  [aw=peso], robust 
local pF=Ftail(150,3,e(F))
outreg2 using "`out2'selection.dta", append  dec(3)  ///
	addstat("p-value (F stat)",`pF')
	
reg treatment_old lnL i.area i.setton3   [aw=peso], robust
local pF=Ftail(150,3,e(F))
outreg2 using "`out2'selection.dta", append  dec(3)  ///
	addstat("p-value (F stat)",`pF')
	
reg treatment_old lnL export4R i.area i.setton3    [aw=peso], robust
local pF=Ftail(150,3,e(F))
outreg2 using "`out2'selection.dta", append  dec(3)  ///
	addstat("p-value (F stat)",`pF')
	
reg treatment_old lnL export4R dpre i.area i.setton3     [aw=peso], robust
local pF=Ftail(150,3,e(F))
outreg2 using "`out2'selection.dta", append  dec(3)  ///
	addstat("p-value (F stat)",`pF')
	
